#！/bin/bash
string="Bigdata process framework is Hadoop,Hadoop is an open source project"
function DelFunc
{
    echo "${string//Hadoop/}"
}

#将Hadoop替换成Helloworld
function SwapAllFunc
{
    echo "${string//Hadoop/Helloworld/}"
}

#替换第一个hellworld
function SwapFristFunc
{
    echo "${string/Hadoop/Helloworld/}"
}

#计算长度
function CalLen
{
    echo "${#string}"
}

while true
do
    echo "**********************"
    echo "1. DelFunc 删除Hadoop"
    echo "2. SwapAllFunc 全部Hadoop替换成Helloworld"
    echo "3. SwapFristFunc 第一个Hadoop替换成Helloworld"
    echo "4. CalLen 计算字符串长度"
    echo "5. Exit 退出"
    echo  "********************"

    read -p "please Choose a function: 1. DelFunc 2. SwapAllFunc 3. SwapFristFunc 4. CalLen 5. Exit: " Choise
    case $Choise in
        1)
            DelFunc
            ;;
        2)
            SwapAllFunc
            ;;
        3)
            SwapFristFunc
            ;;
        4)
            CalLen
            ;;
        5)
            exit 0
            ;;
        *)
            echo "Invalid input, please try again"
            ;;
    esac
done